package com.unione.unione_network.request

import com.unione.unione_base.bean.BaseRobotRepo
import com.unione.unione_network.BaseRepository
import com.unione.unione_network.UnioneClient
import com.unione.unione_network.robot_auto.GuideRobotAppService
import com.unione.unione_network.robot_auto.RobotAutoService
import com.unione.unione_network.robot_auto.bean.ChargeMap
import com.unione.unione_network.robot_auto.bean.MapInfo
import com.unione.unione_network.robot_auto.bean.RobotFile
import com.unione.unione_network.robot_auto.bean.RobotInfo
import com.unione.unione_network.robot_auto.bean.RoutePoint
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Response


/**
 *  联一自主接口
 */
object UnioneRobotRepository : BaseRepository(), RobotAutoService, GuideRobotAppService {

    private val service by lazy {
        UnioneClient.create(
            RobotAutoService::class.java,
            baseRobotUrl
        )
    }

    private val appService by lazy {
        UnioneClient.create(
            GuideRobotAppService::class.java,
            baseRobotUrl
        )
    }

    override suspend fun getMapList(): BaseRobotRepo<List<MapInfo>> {
        return service.getMapList()
    }

    override suspend fun getChargeInfo(): BaseRobotRepo<ChargeMap> {
        return service.getChargeInfo()
    }

    override suspend fun getMapRoadInfo(scene: String): BaseRobotRepo<List<RoutePoint>> {
        return service.getMapRoadInfo(scene)
    }

    override suspend fun getRobotInfo(): BaseRobotRepo<RobotInfo> {
        return service.getRobotInfo()
    }

    override suspend fun setAutoMode(cmd: Int, scene: String, pointId: String): BaseRobotRepo<Any> {
        return service.setAutoMode(cmd, scene, pointId)
    }


    override suspend fun moveToDstPoint(body: RequestBody): BaseRobotRepo<Any> {
        return service.moveToDstPoint(body)
    }

    override suspend fun oneKeyCharge(): BaseRobotRepo<Any> {
        return service.oneKeyCharge()
    }

    override suspend fun setPauseOrResume(cmd: Int): BaseRobotRepo<Any> {
        return service.setPauseOrResume(cmd)
    }

    override suspend fun sendLightCtl(cmd: Int): BaseRobotRepo<Any> {
        return service.sendLightCtl(cmd)
    }

    override suspend fun moveToAnyPoint(body: RequestBody): BaseRobotRepo<Any> {
        return service.moveToAnyPoint(body)
    }

    override suspend fun getFileList(type: String): BaseRobotRepo<List<RobotFile>> {
        return appService.getFileList(type)
    }

    override suspend fun getFile(type: String, fileName: String): Response<ResponseBody> {
        return appService.getFile(type, fileName)
    }

    override suspend fun deleteCommonFile(type: String, fileName: String): BaseRobotRepo<Any> {
        return appService.deleteCommonFile(type, fileName)
    }


}